package com.oig.sys.log.dto;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.oig.common.validator.GroupAdd;

import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;

import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import java.util.Date;

@Schema
@Data
public class SysLogDto {

    /**
     * 操作用户id
     */
    @Schema(description = "操作用户id")
//    @NotNull(message = "参数错误,用户id不能为空", groups= GroupAdd.class)
    private Integer userId;

    /**
     * 操作用户
     */
    @Schema(description = "操作用户")
//    @NotEmpty(message = "参数错误,操作用户名称不能为空", groups= GroupAdd.class)
    private String userName;

    /**
     * 用户ip
     */
    @Schema(description = "操作用户ip")
    private String loginIp;

    /**
     * 操作时间
     */
    @Schema(description = "操作时间", requiredMode = Schema.RequiredMode.NOT_REQUIRED)
    @NotNull(message = "参数错误,操作时间不能为空", groups= GroupAdd.class)
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date optTime;

    @Schema(description = "操作时间  查询时间范围")
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date startOptTime;

    @Schema(description = "操作时间  查询时间范围")
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date endOptTime;

    /**
     * 系统id
     */
    @Schema(description = "系统id")
    private Integer systemId;

    /**
     * 菜单id
     */
    @Schema(description = "菜单id")
    private Integer resourceId;

    /**
     * 操作类型
     */
    @Schema(description = "操作类型", requiredMode = Schema.RequiredMode.NOT_REQUIRED)
    @NotEmpty(message = "参数错误,操作类型不能为空", groups= GroupAdd.class)
    private String optType;

    /**
     * 请求url
     */
    @Schema(description = "请求url")
    private String apiUrl;

    /**
     * 操作记录id
     */
    @Schema(description = "操作记录id")
    private String optObjId;

    /**
     * 操作内容
     */
    @Schema(description = "操作内容")
    private String content;

    /**
     * 参数json
     */
    @Schema(description = "参数json")
    private String oldval;

    /**
     * 返回值json
     */
    @Schema(description = "返回值json")
    private String newval;

    /**
     * 备注
     */
    @Schema(description = "备注")
    private String remark;

    /**
     * 0-成功 1-失败
     */
    @Schema(description = "操作结果：0-成功 1-失败")
    private String result;

    /**
     * 执行时长
     */
    @Schema(description = "执行时长")
    private Long exeTime;

    /**
     * 异常
     */
    @Schema(description = "异常")
    private String exception;


    @Schema(description = "跟踪号")
    private String traceId;

    @Schema(description = "操作用户所属租户id")
    private Integer tenantId;
    @Schema(description = "操作用户所属租户名称")
    private String tenantName;
}
